package proxypattern.impl;


import lombok.Getter;
import proxypattern.base.BaseState;
import proxypattern.entity.RemoteGumballMachine;

/**
 * 糖果机未接收25美分状态
 * 我们要做的事情,是实现适合我们所在的这个状态的行为
 * 在某些情况下,这个行为会让糖果机的状态改变
 * @author yaojianfeng
 */
public class NoQuarterStateImpl implements BaseState {
    @Getter
    private String desc = "等待投币";
    private transient RemoteGumballMachine gumballMachine;

    /**
     * 我们通过构造器得到糖果机的引用,然后将它记录在实例变量中
     * @param gumballMachine 糖果机对象
     */
    public NoQuarterStateImpl(RemoteGumballMachine gumballMachine) {
        this.gumballMachine = gumballMachine;
    }

    @Override
    public void insertQuarter() {
        System.out.println("已投币25美分!");
        gumballMachine.setState(gumballMachine.getHasQuarterState());
    }

    @Override
    public void ejectQuarter() {
        System.out.println("未投币,请投币! 你想坑老子的钱?");
    }

    @Override
    public void turnCrank() {
        System.out.println("未投币,转动曲柄无法出货!");
    }

    @Override
    public void dispense() {
        System.out.println("未接收到硬币,不能给你糖果哟!");
    }
}
